<template>
    <div id="root">
        <span>账号</span><input type="text" v-model="v1"><br>
        <span>密码</span><input type="text" v-model="v2"><br>
        <button @click="getRequest">get请求</button>
        <button @click="postRequest">post请求</button>
    </div>
</template>

<script>
    import qs from "../../node_modules/querystring"
    export default {
        name: "Networking",
        data: () => {
            return {
                v1: "",
                v2: "",
            }
        },
        methods: {
            postRequest() {
                this.axios.post("/api/post",qs.stringify(
                  {
                        username: this.v1,
                        password: this.v2
                    })
                ).then(data => {
                    console.log(data.data);
                }).catch(error => {
                })
            },
            getRequest() {
                this.axios.get("/api/get", {
                    params: {
                        username: this.v1,
                        password: this.v2
                    }
                }).then(data => {
                    console.log(data.data)
                }).catch(error => {
                    console.log(error)
                });
            },
        }


    }
</script>

<style scoped>

</style>